### I6_P12_1_age

I6_P12_1_age_t <- as.data.table(svyby(~I6_P12_1, ~M2, srs_treatment, svymean, na = TRUE))

I6_P12_1_age_t[, Status := "Treatment"]

I6_P12_1_age_c <- as.data.table(svyby(~I6_P12_1, ~M2, srs_control, svymean, na = TRUE))

I6_P12_1_age_c[, Status := "Control"]

I6_P12_1_age <- rbind(I6_P12_1_age_t, I6_P12_1_age_c)

I6_P12_1_age <- I6_P12_1_age[, .(M2, I6_P12_1 = I6_P12_1*100, se = se*100, Status)]

I6_P12_1_age$M2 <- factor(I6_P12_1_age$M2, levels = unique(I6_P12_1_age$M2))

I6_P12_1_age_p  <- ggplot(I6_P12_1_age, aes(x = M2, y=I6_P12_1, fill = Status)) + 
  geom_bar(stat="identity", color="black", 
           position=position_dodge()) +
  geom_errorbar(aes(ymin = I6_P12_1 - se, 
                    ymax = I6_P12_1 + se), width=.2,
                position=position_dodge(.9)) +
  theme_light() + scale_fill_manual (values=c("dodgerblue4", "gold1", "darkgrey")) + 
  theme(axis.text.x = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        axis.text.y = element_text(color = "grey20", size = 20, angle = 0, hjust = 1, vjust = 0, face = "plain"),  
        axis.title.x = element_text(color = "grey20", size = 20, angle = 0, hjust = .5, vjust = 0, face = "plain"),
        axis.title.y = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        legend.text = element_text(color = "grey20", size = 20, hjust = .5, vjust = .5, face = "plain"),
        legend.title = element_text(color = "grey20", size = 20, face = "plain"),
        legend.position="bottom",
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "grey20")) +
  labs(x = "Age", y = "Share of respondets (%)", color='Treatment status')

ggsave("I6_P12_1_age_p.jpeg", device='jpeg', dpi=900)

### I6_P12_2_age

I6_P12_2_age_t <- as.data.table(svyby(~I6_P12_2, ~M2, srs_treatment, svymean, na = TRUE))

I6_P12_2_age_t[, Status := "Treatment"]

I6_P12_2_age_c <- as.data.table(svyby(~I6_P12_2, ~M2, srs_control, svymean, na = TRUE))

I6_P12_2_age_c[, Status := "Control"]

I6_P12_2_age <- rbind(I6_P12_2_age_t, I6_P12_2_age_c)

I6_P12_2_age <- I6_P12_2_age[, .(M2, I6_P12_2 = I6_P12_2*100, se = se*100, Status)]

I6_P12_2_age$M2 <- factor(I6_P12_2_age$M2, levels = unique(I6_P12_2_age$M2))

I6_P12_2_age_p <- ggplot(I6_P12_2_age, aes(x = M2, y=I6_P12_2, fill = Status)) + 
  geom_bar(stat="identity", color="black", 
           position=position_dodge()) +
  geom_errorbar(aes(ymin = I6_P12_2 - se, 
                    ymax = I6_P12_2 + se), width=.2,
                position=position_dodge(.9)) +
  theme_light() + scale_fill_manual (values=c("dodgerblue4", "gold1", "darkgrey")) + 
  theme(axis.text.x = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        axis.text.y = element_text(color = "grey20", size = 20, angle = 0, hjust = 1, vjust = 0, face = "plain"),  
        axis.title.x = element_text(color = "grey20", size = 20, angle = 0, hjust = .5, vjust = 0, face = "plain"),
        axis.title.y = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        legend.text = element_text(color = "grey20", size = 20, hjust = .5, vjust = .5, face = "plain"),
        legend.title = element_text(color = "grey20", size = 20, face = "plain"),
        legend.position="bottom",
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "grey20")) +
  labs(x = "Age", y = "Share of respondets (%)", color='Treatment status') + ylim(0, 45)

ggsave("I6_P12_2_age_p.jpeg", device='jpeg', dpi=900)

### I6_P12_3_age

I6_P12_3_age_t <- as.data.table(svyby(~I6_P12_3, ~M2, srs_treatment, svymean, na = TRUE))

I6_P12_3_age_t[, Status := "Treatment"]

I6_P12_3_age_c <- as.data.table(svyby(~I6_P12_3, ~M2, srs_control, svymean, na = TRUE))

I6_P12_3_age_c[, Status := "Control"]

I6_P12_3_age <- rbind(I6_P12_3_age_t, I6_P12_3_age_c)

I6_P12_3_age <- I6_P12_3_age[, .(M2, I6_P12_3 = I6_P12_3*100, se = se*100, Status)]

I6_P12_3_age$M2 <- factor(I6_P12_3_age$M2, levels = unique(I6_P12_3_age$M2))

I6_P12_3_age_p <- ggplot(I6_P12_3_age, aes(x = M2, y=I6_P12_3, fill = Status)) + 
  geom_bar(stat="identity", color="black", 
           position=position_dodge()) +
  geom_errorbar(aes(ymin = I6_P12_3 - se, 
                    ymax = I6_P12_3 + se), width=.2,
                position=position_dodge(.9)) +
  theme_light() + scale_fill_manual (values=c("dodgerblue4", "gold1", "darkgrey")) + 
  theme(axis.text.x = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        axis.text.y = element_text(color = "grey20", size = 20, angle = 0, hjust = 1, vjust = 0, face = "plain"),  
        axis.title.x = element_text(color = "grey20", size = 20, angle = 0, hjust = .5, vjust = 0, face = "plain"),
        axis.title.y = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        legend.text = element_text(color = "grey20", size = 20, hjust = .5, vjust = .5, face = "plain"),
        legend.title = element_text(color = "grey20", size = 20, face = "plain"),
        legend.position="bottom",
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "grey20")) +
  labs(x = "Age", y = "Share of respondets (%)", color='Treatment status')

ggsave("I6_P12_3_age_p.jpeg", device='jpeg', dpi=900)

### I6_P12_4_age

I6_P12_4_age_t <- as.data.table(svyby(~I6_P12_4, ~M2, srs_treatment, svymean, na = TRUE))

I6_P12_4_age_t[, Status := "Treatment"]

I6_P12_4_age_c <- as.data.table(svyby(~I6_P12_4, ~M2, srs_control, svymean, na = TRUE))

I6_P12_4_age_c[, Status := "Control"]

I6_P12_4_age <- rbind(I6_P12_4_age_t, I6_P12_4_age_c)

I6_P12_4_age <- I6_P12_4_age[, .(M2, I6_P12_4 = I6_P12_4*100, se = se*100, Status)]

I6_P12_4_age$M2 <- factor(I6_P12_4_age$M2, levels = unique(I6_P12_4_age$M2))

I6_P12_4_age_p <- ggplot(I6_P12_4_age, aes(x = M2, y=I6_P12_4, fill = Status)) + 
  geom_bar(stat="identity", color="black", 
           position=position_dodge()) +
  geom_errorbar(aes(ymin = I6_P12_4 - se, 
                    ymax = I6_P12_4 + se), width=.2,
                position=position_dodge(.9)) +
  theme_light() + scale_fill_manual (values=c("dodgerblue4", "gold1", "darkgrey")) + 
  theme(axis.text.x = element_text(color = "grey20", size = 20, angle = 90, hjust = .4, vjust = .5, face = "plain"),
        axis.text.y = element_text(color = "grey20", size = 20, angle = 0, hjust = 1, vjust = 0, face = "plain"),  
        axis.title.x = element_text(color = "grey20", size = 20, angle = 0, hjust = .5, vjust = 0, face = "plain"),
        axis.title.y = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        legend.text = element_text(color = "grey20", size = 20, hjust = .5, vjust = .5, face = "plain"),
        legend.title = element_text(color = "grey20", size = 20, face = "plain"),
        legend.position="bottom",
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "grey20")) +
  labs(x = "Age", y = "Share of respondets (%)", color='Treatment status') +
  ylim(0, 60)

ggsave("I6_P12_4_age_p.jpeg", device='jpeg', dpi=900)

### I6_P12_5_age

I6_P12_5_age_t <- as.data.table(svyby(~I6_P12_5, ~M2, srs_treatment, svymean, na = TRUE))

I6_P12_5_age_t[, Status := "Treatment"]

I6_P12_5_age_c <- as.data.table(svyby(~I6_P12_5, ~M2, srs_control, svymean, na = TRUE))

I6_P12_5_age_c[, Status := "Control"]

I6_P12_5_age <- rbind(I6_P12_5_age_t, I6_P12_5_age_c)

I6_P12_5_age <- I6_P12_5_age[, .(M2, I6_P12_5 = I6_P12_5*100, se = se*100, Status)]

I6_P12_5_age$M2 <- factor(I6_P12_5_age$M2, levels = unique(I6_P12_5_age$M2))

I6_P12_5_age_p <- ggplot(I6_P12_5_age, aes(x = M2, y=I6_P12_5, fill = Status)) + 
  geom_bar(stat="identity", color="black", 
           position=position_dodge()) +
  geom_errorbar(aes(ymin = I6_P12_5 - se, 
                    ymax = I6_P12_5 + se), width=.2,
                position=position_dodge(.9)) +
  theme_light() + scale_fill_manual (values=c("dodgerblue4", "gold1", "darkgrey")) + 
  theme(axis.text.x = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        axis.text.y = element_text(color = "grey20", size = 20, angle = 0, hjust = 1, vjust = 0, face = "plain"),  
        axis.title.x = element_text(color = "grey20", size = 20, angle = 0, hjust = .5, vjust = 0, face = "plain"),
        axis.title.y = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        legend.text = element_text(color = "grey20", size = 20, hjust = .5, vjust = .5, face = "plain"),
        legend.title = element_text(color = "grey20", size = 20, face = "plain"),
        legend.position="bottom",
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "grey20")) +
  labs(x = "Age", y = "Share of respondets (%)", color='Treatment status')

ggsave("I6_P12_5_age_p.jpeg", device='jpeg', dpi=900)

### I6_P12_6_age

I6_P12_6_age_t <- as.data.table(svyby(~I6_P12_6, ~M2, srs_treatment, svymean, na = TRUE))

I6_P12_6_age_t[, Status := "Treatment"]

I6_P12_6_age_c <- as.data.table(svyby(~I6_P12_6, ~M2, srs_control, svymean, na = TRUE))

I6_P12_6_age_c[, Status := "Control"]

I6_P12_6_age <- rbind(I6_P12_6_age_t, I6_P12_6_age_c)

I6_P12_6_age <- I6_P12_6_age[, .(M2, I6_P12_6 = I6_P12_6*100, se = se*100, Status)]

I6_P12_6_age$M2 <- factor(I6_P12_6_age$M2, levels = unique(I6_P12_6_age$M2))

I6_P12_6_age_p <- ggplot(I6_P12_6_age, aes(x = M2, y=I6_P12_6, fill = Status)) + 
  geom_bar(stat="identity", color="black", 
           position=position_dodge()) +
  geom_errorbar(aes(ymin = I6_P12_6 - se, 
                    ymax = I6_P12_6 + se), width=.2,
                position=position_dodge(.9)) +
  theme_light() + scale_fill_manual (values=c("dodgerblue4", "gold1", "darkgrey")) + 
  theme(axis.text.x = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        axis.text.y = element_text(color = "grey20", size = 20, angle = 0, hjust = 1, vjust = 0, face = "plain"),  
        axis.title.x = element_text(color = "grey20", size = 20, angle = 0, hjust = .5, vjust = 0, face = "plain"),
        axis.title.y = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        legend.text = element_text(color = "grey20", size = 20, hjust = .5, vjust = .5, face = "plain"),
        legend.title = element_text(color = "grey20", size = 20, face = "plain"),
        legend.position="bottom",
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "grey20")) +
  labs(x = "Age", y = "Share of respondets (%)", color='Treatment status')

ggsave("I6_P12_6_age_p.jpeg", device='jpeg', dpi=900)

### I6_P12_7_age

I6_P12_7_age_t <- as.data.table(svyby(~I6_P12_7, ~M2, srs_treatment, svymean, na = TRUE))

I6_P12_7_age_t[, Status := "Treatment"]

I6_P12_7_age_c <- as.data.table(svyby(~I6_P12_7, ~M2, srs_control, svymean, na = TRUE))

I6_P12_7_age_c[, Status := "Control"]

I6_P12_7_age <- rbind(I6_P12_7_age_t, I6_P12_7_age_c)

I6_P12_7_age <- I6_P12_7_age[, .(M2, I6_P12_7 = I6_P12_7*100, se = se*100, Status)]

I6_P12_7_age$M2 <- factor(I6_P12_7_age$M2, levels = unique(I6_P12_7_age$M2))

I6_P12_7_age_p <- ggplot(I6_P12_7_age, aes(x = M2, y=I6_P12_7, fill = Status)) + 
  geom_bar(stat="identity", color="black", 
           position=position_dodge()) +
  geom_errorbar(aes(ymin = I6_P12_7 - se, 
                    ymax = I6_P12_7 + se), width=.2,
                position=position_dodge(.9)) +
  theme_light() + scale_fill_manual (values=c("dodgerblue4", "gold1", "darkgrey")) + 
  theme(axis.text.x = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        axis.text.y = element_text(color = "grey20", size = 20, angle = 0, hjust = 1, vjust = 0, face = "plain"),  
        axis.title.x = element_text(color = "grey20", size = 20, angle = 0, hjust = .5, vjust = 0, face = "plain"),
        axis.title.y = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        legend.text = element_text(color = "grey20", size = 20, hjust = .5, vjust = .5, face = "plain"),
        legend.title = element_text(color = "grey20", size = 20, face = "plain"),
        legend.position="bottom",
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "grey20")) +
  labs(x = "Age", y = "Share of respondets (%)", color='Treatment status')

ggsave("I6_P12_7_age_p.jpeg", device='jpeg', dpi=900)

### I6_P12_8_age

I6_P12_8_age_t <- as.data.table(svyby(~I6_P12_8, ~M2, srs_treatment, svymean, na = TRUE))

I6_P12_8_age_t[, Status := "Treatment"]

I6_P12_8_age_c <- as.data.table(svyby(~I6_P12_8, ~M2, srs_control, svymean, na = TRUE))

I6_P12_8_age_c[, Status := "Control"]

I6_P12_8_age <- rbind(I6_P12_8_age_t, I6_P12_8_age_c)

I6_P12_8_age <- I6_P12_8_age[, .(M2, I6_P12_8 = I6_P12_8*100, se = se*100, Status)]

I6_P12_8_age$M2 <- factor(I6_P12_8_age$M2, levels = unique(I6_P12_8_age$M2))

I6_P12_8_age_p <- ggplot(I6_P12_8_age, aes(x = M2, y=I6_P12_8, fill = Status)) + 
  geom_bar(stat="identity", color="black", 
           position=position_dodge()) +
  geom_errorbar(aes(ymin = I6_P12_8 - se, 
                    ymax = I6_P12_8 + se), width=.2,
                position=position_dodge(.9)) +
  theme_light() + scale_fill_manual (values=c("dodgerblue4", "gold1", "darkgrey")) + 
  theme(axis.text.x = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        axis.text.y = element_text(color = "grey20", size = 20, angle = 0, hjust = 1, vjust = 0, face = "plain"),  
        axis.title.x = element_text(color = "grey20", size = 20, angle = 0, hjust = .5, vjust = 0, face = "plain"),
        axis.title.y = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
        legend.text = element_text(color = "grey20", size = 20, hjust = .5, vjust = .5, face = "plain"),
        legend.title = element_text(color = "grey20", size = 20, face = "plain"),
        legend.position="bottom",
        legend.background = element_blank(),
        legend.box.background = element_rect(colour = "grey20")) +
  labs(x = "Age", y = "Share of respondets (%)", color='Treatment status') +
  ylim(0, 60)

ggsave("I6_P12_8_age_p.jpeg", device='jpeg', dpi=900)


